<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      while (true) {
        let count = 0
        let n = +prompt('请输入一个正整数')
        if (n <= 0) {
          alert('请输入一个正整数')
        } else {
          for (let i = 2; i <= n; i++) {
            if (n % i == 0) {
              count++
            }
          }
          if (count > 1 || count == 0) {
            //count为0是num为1时，1不是质数
            alert(n + '不是质数')
          } else {
            alert(n + '是质数')
          }
        }
      }

    </script>
  </body>
</html>
